#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <memory.h>
int* temp;
int tempSize;

bool check(int mask, int k, int n) {
    tempSize = 0;
    int sum = 0;
    for (int i = 0; i < 9; ++i) {
        if ((1 << i) & mask) {
            temp[tempSize++] = i + 1;
            sum += i + 1;
        }
    }
    return tempSize == k && sum == n;
}

int** combinationSum3(int k, int n, int* returnSize, int** returnColumnSizes) {
    *returnColumnSizes = malloc(sizeof(int) * 2001);
    int** ret = malloc(sizeof(int*) * 2001);
    temp = malloc(sizeof(int) * 2001);
    *returnSize = 0;

    for (int mask = 0; mask < (1 << 9); ++mask) {
        if (check(mask, k, n)) {
            int* tmp = malloc(sizeof(int) * tempSize);
            memcpy(tmp, temp, sizeof(int) * tempSize);
            ret[*returnSize] = tmp;
            (*returnColumnSizes)[(*returnSize)++] = tempSize;
        }
    }
    return ret;
}


int main()
{
	return 0;
}